﻿using System;
using System.Web;
using SharedLibraries;

namespace ThangNM
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            ////URLRewriter.sRoot = CSharp.Properties.Settings.Default.Root;
            //URLRewriter.bSyncMapUrl = true;
            //URLRewriter.RegisterRoutes(null, null);

            //System.Timers.Timer myTimer = new System.Timers.Timer();
            //myTimer.Interval = 20000; // Set the Interval to 5 seconds (5000 milliseconds).
            //myTimer.AutoReset = true;
            //myTimer.Elapsed += new System.Timers.ElapsedEventHandler(URLRewriter.RegisterRoutes);
            //myTimer.Enabled = true;



            //Code that runs on application startup
            //System.Timers.Timer myTimer = new System.Timers.Timer();
            //myTimer.Interval = 20000; // Set the Interval to 5 seconds (5000 milliseconds).
            //myTimer.AutoReset = true;
            //myTimer.Elapsed += new System.Timers.ElapsedEventHandler(ScheduleJobs.Job_Frequency_3m);
            //myTimer.Enabled = true;
        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {
            if (HttpContext.Current.Request.Url.ToString().ToLower().Contains(System.Configuration.ConfigurationManager.AppSettings["WWWHOMEPAGE"]))
            {
                HttpContext.Current.Response.Status = "301 Moved Permanently";
                HttpContext.Current.Response.AddHeader("Location", Request.Url.ToString().ToLower().Replace(System.Configuration.ConfigurationManager.AppSettings["WWWHOMEPAGE"], System.Configuration.ConfigurationManager.AppSettings["HOMEPAGE"]));
            }
        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {

        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}